package cn.yunhe.servlet;

import cn.yunhe.dao.IFoodDaoMapper;
import cn.yunhe.services.DeleteFoodService;
import cn.yunhe.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 周依博
 *
 * 菜品删除的servlet
 * @param
 * @return
 */
@WebServlet("/shangjia/DeleteFoodServlet")
public class DeleteFoodServlet extends HttpServlet {


    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            int foodid= Integer.parseInt(request.getParameter("fid"));
        DeleteFoodService deleteFoodService = new DeleteFoodService();
            PrintWriter out = response.getWriter();
            if (deleteFoodService.deleteFood(foodid)>0){
                out.print(1);
            }else {
                out.print(0);
            }

    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
